package cn.lanqiao.dao;

import cn.lanqiao.entity.User;


import java.io.UnsupportedEncodingException;
import java.sql.*;
import java.util.ArrayList;
import java.util.List;


public class UserJDBCDao extends BaseDao<User> {


    public List<User> query() {
        return executeQuery("select * from user");
    }

    public int insert(User userBean) {
        return executeUpdate("insert into user (username,password) values (?,?) ", userBean.getUserName(), userBean.getPassword());
    }

    public int update(User userBean) {
        return executeUpdate("update user set username = ? , password = ? where id = ? ", userBean.getUserName(), userBean.getPassword(), userBean.getUserId());
    }

    public int delete(User userBean) {
        return executeUpdate("delete from user where id = ? ", userBean.getUserId());
    }


    public static void main(String[] args) throws UnsupportedEncodingException {
//        System.out.println(new UserDao().delete(new User("david", "123456")));
        System.out.println(new UserJDBCDao().query());
    }
}
